#include "Arca.h"
Arca::Arca()
{
    int i=0;
    (*this).Animale[i]=new Pisica;
    (*this).Animale[i]->setSex(male);
    i++;
    (*this).Animale[i]=new Pisica;
    (*this).Animale[i]->setSex(female);
    i++;
    (*this).Animale[i]=new Soarece;
    (*this).Animale[i]->setSex(male);
    i++;
    (*this).Animale[i]=new Soarece;
    (*this).Animale[i]->setSex(female);
    i++;
    (*this).Animale[i]=new Caine;
    (*this).Animale[i]->setSex(male);
    i++;
    (*this).Animale[i]=new Caine;
    (*this).Animale[i]->setSex(female);
    i++;
    (*this).Animale[i]=new Rata;
    (*this).Animale[i]->setSex(male);
    i++;
    (*this).Animale[i]=new Rata;
    (*this).Animale[i]->setSex(female);
    i++;
    (*this).Animale[i]=new Papagal;
    (*this).Animale[i]->setSex(male);
    i++;
    (*this).Animale[i]=new Papagal;
    (*this).Animale[i]->setSex(female);
    i++;
    (*this).Animale[i]=new Crocodil;
    (*this).Animale[i]->setSex(male);
    i++;
    (*this).Animale[i]=new Crocodil;
    (*this).Animale[i]->setSex(female);
    i++;
    (*this).Animale[i]=new Sarpe;
    (*this).Animale[i]->setSex(male);
    i++;
    (*this).Animale[i]=new Sarpe;
    (*this).Animale[i]->setSex(female);
    i++;
    (*this).nrAnimale=i;
    (*this).time=0;
}
int Arca::getTime()
{
    return this->time;
}
int Arca::getNrAnimale()
{
    return (*this).nrAnimale;
}
void Arca::printArca()
{
    std::cout<<"Animalele aflate pe arca dupa: "<<(*this).time<<" luni \n";
    for(int i=0; i<(*this).nrAnimale;i++) this->Animale[i]->print();
}
void Arca::addAnimal(Animal* k)
{
    int i=(*this).getNrAnimale();
    (*this).Animale[i]=k;
    i++;
    (*this).nrAnimale=i;
}
void Arca::passTime(int nrLuni)
{
    int k=(*this).getNrAnimale(),l;
    int varsta;
    for(int j=0;j<nrLuni;j++)
    {
    for(int i=0; i<k;i++)
    {
        this->Animale[i]->addVarsta(1);
        if (this->Animale[i]->getVarsta()>this->Animale[i]->getLimitaVarsta())
        {
         (*this).Animale[i]->distruge();
         for (int j=i;j<k-1;j++) (*this).Animale[j]=(*this).Animale[j+1];
         (*this).nrAnimale--;
        };
        if(this->Animale[i]->isGestant()) addAnimal(this->Animale[i]->giveBirth());
    	if (this->Animale[i]->getSpecie()==pisica && this->Animale[i]->getVarsta()%20==0)
        {   
         for (l=0;l<k;l++) if(this->Animale[l]->getSpecie()==soarece) break;
	if(l!=k) 
		{
		(*this).Animale[l]->distruge();
		for (int j=l;j<k-1;j++) (*this).Animale[j]=(*this).Animale[j+1];
		(*this).nrAnimale--;
		} 
        }
    }
     }   (*this).time=(*this).time+nrLuni;
}
